package com.credit.util;

import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.data.redis.core.RedisTemplate;



public class ApplicationContextUtils implements ApplicationContextAware {
 	private static ApplicationContext application;

	@SuppressWarnings("static-access")
	public void setApplicationContext(ApplicationContext application)
			throws BeansException {
		this.application = application;
	}
	

	public static Object getBean(String id){
		if (application == null) {
			//application = new ClassPathXmlApplicationContext(
			//		"classpath*:config/spring/spring-*.xml");
			return null;
		}
		
		return application.getBean(id);
	}
	

	@SuppressWarnings("rawtypes")
	public static RedisTemplate getRedisPostTemplate(){
		return (RedisTemplate)application.getBean("redisPostTemplate");
	}

/*	public static MemCachedClientWrapper getCommonMemCacheTemplate(){
		return (MemCachedClientWrapper)application.getBean("memcached");
	}*/
	

}
